package com.xikeda.controller;

import com.xikeda.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class DemoController {
    @Resource
    private DemoService demoService;
    @RequestMapping("/test2")
    public String testDemo(HttpServletRequest request, HttpServletResponse response){
        //接受页面穿过来的数据
        String id = request.getParameter("id");
        String password =request.getParameter("password");
        System.out.println(id);
        System.out.print(password);
        Integer idd = Integer.valueOf(id);
        if(id!=null){
            String name = demoService.findNameById(idd);
            System.out.println("数据库中的name为："+name );
        }else{
            System.out.println("id为空");

        }
     return "demo";
    }
    @RequestMapping("test1")
    public String Demo1(HttpServletRequest request,HttpServletResponse response){
        return "demo";
    }
}